<template>
    <div>
        <h3>
        标题
        </h3>
        <p>
            <span>发表时间：</span>
            <span>点击：</span>
        </p>
        <hr>
    
      <!-- <img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100" @click="$preview.open(index, list)" :key="item.src"> -->
    <vue-preview class="preview" :slides="list"></vue-preview>
         <!-- <ul>
      <li v-for="item in list" :key="item.url">
        <img :src="item.src" alt="">
      </li>
    </ul>  -->
    </div>
</template>
<script>
export default {
  data() {
    return {
      id: this.$route.params.id, // 从路由中获取到的 图片Id
      photoinfo: {}, // 图片详情
      list: [] // 缩略图的数组
    };
  },
  created() {
    this.getPhotoInfo();
    this.getThumbs();
  },
  methods: {
    getPhotoInfo() {
      // 获取图片的详情
      this.$http.get("../../data/dataphoto.json").then(result => {
        if (result.body.status === 0) {
          this.photoinfo = result.body.message[0];
        }
      });
    },
    getThumbs() {
      // 获取缩略图
      this.$http.get("../../data/photolist.json").then(result => {
        if (result.body.status === 0) {
          // 循环每个图片数据，补全图片的宽和高
            result.body.message.forEach(item=> {
            item.w = 600;
            item.h = 400;
            item.msrc=item.src=item.src;
            
          })
          // 把完整的数据保存到 list 中
           this.list = result.body.message;
        }
      })
    }
  }
}
</script>
<style lang="sass" scoped>
.preview{
 img{
   width:300px;
   height:400px;
}
}
</style>